package l1j.server.server.clientpackets;

import java.util.logging.Level;
import java.util.logging.Logger;

import l1j.server.echo.ClientThread;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.serverpackets.S_PacketBox;

	/**
	 * 處理收到由客戶端傳來選擇新角色的封包
	 */
	public class C_NewCharSelect extends ClientBasePacket {
		private static final String C_NEW_CHAR_SELECT = "[C] C_NewCharSelect";
		private static Logger _log = Logger.getLogger(C_NewCharSelect.class.getName());

		@Override
		public String getType() {
			return C_NEW_CHAR_SELECT;
		}
	@Override
	public void start(final byte[] decrypt, final ClientThread client) {
		try {
			// 資料載入
			this.read(decrypt);

		final L1PcInstance pc = client.getActiveChar();

		//Thread.sleep(5000);
		if (pc == null) {
			return;
		}
		client.CharReStart(true);

		_log.fine("Disconnect from: " + pc.getName());
		try {
			Thread.sleep(250);
		} catch (final InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		client.quitGame();

		client.out().encrypt(new S_PacketBox()); // 2.70C->3.0で追加

		} catch (final Exception e) {
			_log.log(Level.SEVERE, e.getLocalizedMessage(), e);

				} finally {
					this.over();
				}
}
}
